<!DOCTYPE html>
<html>
<head>
  <title></title>
</head>
<body>
<style>
  #app {
    font-family: Roboto, sans-serif;
    color: #363e4f;
  }
  .data-label {
    display: inline-block;
    width: 160px;
  }
</style>
<div id="app">
  <p><strong class="data-label">A</strong><input type="text" v-model="a"></p>
  <p><strong class="data-label">B</strong><input type="text" v-model="b"></p>
  <p><strong class="data-label">C=A*2+2</strong>{{ c }}</p>
  <p><strong class="data-label">D=A+B*2</strong>{{ d }}</p>
  <p><strong class="data-label">E=B/2</strong>{{ e }}</p>
  <p><strong class="data-label">F=C+D</strong>{{ f }}</p>
  <p><strong class="data-label">G=D-E</strong>{{ g }}</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.min.js"></script>
<script type="text/javascript">
  let vm = new Vue({
    el: '#app',
    data () {
      return {
        a: 3,
        b: 4
      }
    },
    computed: { // 计算属性
      c () {
        return this.a * 2 + 2
      },
      d () {
        return Number(this.a) + this.b * 2
      },
      e () {
        return this.b / 2
      },
      f () {
        return Number(this.c) + Number(this.d)
      },
      g () {
        return this.d - this.e
      }
    },
    methods: {
      getC (suf) {
        return this.a * 2 + (suf || 2)
      }
    }
  })
</script>
</body>
</html>